package d0317;
import java.util.Scanner;
public class stopWaitThread {
    public static void main(String[] args) {
        IOWaitThread stopIOWaitThread = new IOWaitThread();
        System.out.println("线程启动");
        stopIOWaitThread.start();
        try {
            Thread.sleep(100);
        } catch (InterruptedException e) {
            e.printStackTrace();
        }
        stopIOWaitThread.interrupt();
    }
}

class IOWaitThread extends Thread{
    Scanner scanner = new Scanner(System.in);
    private boolean flag=true;

    @Override
    public void run() {
        while (flag){
            System.out.println("等待用户输入：");
            scanner.next();
        }
    }

    public void stopThread(){
        flag=false;
    }
}